package com.example.freeengine.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;

import com.example.freeengine.R;
import com.example.freeengine.databinding.FreeengineFragmentBinding;
import com.example.freeengine.filetranslate.FileTranslateFragment;

/**
 * @author Terry Deng
 */
public class FreeEngineFragment extends Fragment {

    private FreeEngineViewModel mViewModel;
    private FreeengineFragmentBinding viewBinding;

    public static FreeEngineFragment newInstance() {
        return new FreeEngineFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        viewBinding = FreeengineFragmentBinding.inflate(inflater);
        return viewBinding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mViewModel = new ViewModelProvider(this).get(FreeEngineViewModel.class);

        viewBinding.cvFreeEngineWallpaper.setOnClickListener(v -> {
            NavController navController = Navigation.findNavController(v);
            navController.navigate(R.id.action_freeEngineFragment_to_wallPaperFragment);
        });

        viewBinding.cvFreeEngineFileTranslate.setOnClickListener(v -> {
            startActivity(new Intent(requireActivity(), FileTranslateFragment.class));
        });

    }

}